<template>
  <div>
    <el-dialog v-bind="$attrs">
      <super-form
        label-width="120px"
        size="middle"
        form-ref="modalForm"
        :form-data="formData"
        :render-form-item="renderFormItem"
        :form-buttons="formButtons"
      />
    </el-dialog>
  </div>
</template>

<script>
import SuperForm from '@/components/SuperForm'
import { updateFormItem } from './config'
import { fetchDropBustList } from '@/api/commonDropDown'
export default {
  components: {
    SuperForm
  },
  props: {
    deviceCodeDisabled: {
      type: Boolean,
      default: false
    },
    handleSubmit: {
      type: Function,
      default: () => {}
    },
    formData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      renderFormItem: [],
      formButtons: {
        isDialog: true,
        submitName: '提交',
        resetName: '取消',
        submitCallback: values => this.handleSubmit(values),
        resetCallback: () => this.$emit('update:visible', false)
      }
    }
  },
  created() {
    this.getBuss()
  },
  // watch: {
  //   deviceCodeDisabled: {
  //     handler: function() {
  //       this.renderFormItem = updateFormItem(this.deviceCodeDisabled)
  //     },
  //     immediate: true
  //   }
  // },
  methods: {
    name() {},
    async getBuss() {
      let list = await fetchDropBustList()
      list = list.map(item => {
        item.key = item.id
        item.value = item.name
        return item
      })
      this.renderFormItem = updateFormItem(list)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog__header {
  border-bottom: 1px solid #eaeaea;
}
</style>
